<?php
/*
* @Author: 李明
* @Date: 2021-12-01 23:00:03
 * @LastEditTime: 2021-12-01 23:05:47
 * @LastEditors: 李明
* @Description:
 * @FilePath: /CRM2.0-PHP/app/Http/Controllers/OaManagement/OAPayController.php
* @山东壹零贰肆信息科技有限公司
*/

use App\Http\Controllers\common\LMReturn;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\FamiliesMoneyRecord;
use Illuminate\Support\Facades\DB;

class OAPayController extends Controller
{
    /**
     * @description: 打款中改为已打款（出纳）
     * @param {Request} $request
     *
     */
    public function OAPayCaiWu(Request $request)
    {
        //去验证token值
        $tokenInfo = json_decode($this->verifyTokenLm(), true);
        //判断传递过来的token的code码是否等于400  如果是400的话，提示token不正确
        if ($tokenInfo['code'] == 400) {
            return LMReturn::Error($tokenInfo['msg'], $tokenInfo['code']);
        }
        try {
            $all = $request->all();
            $worker_id = $tokenInfo['worker_id'];
            $oa_id = $all['oa_id'];
            $oa_fin = FamiliesMoneyRecord::find($oa_id);
        } catch (\Throwable $th) {
            return LMReturn::Error('请检查传参，或者记录不存在', 'OPC006');
        }
        try {
            $oa_fin->status = 4; // 1审核中  2通过/待打款  3拒绝 4打款中 5已打款
        } catch (\Throwable $th) {
            return LMReturn::Error('进入打款状态失败', 'OAC001');
        }
    }
}
